package com.yanggu.scala.chapater07.extend

object ScalaFieldOverrideDemo02 {

  def main(args: Array[String]): Unit = {

    //1. val只能重写另一个val或者不带参数的def
    //2. def只能重写另一个方法
    //3. var只能重写另一个抽象的var
    val aaa = new AAAA
    val bbb = new BBBB
    println(aaa.age)
    println(bbb.age)
  }

}

class AAAA {

  //这里运行报错，编译不报错
//  var age : Int = 10

  val age : Int = 20
}

class BBBB extends AAAA {

  override val age: Int = 20

}